package com.woniu.shop.utils;

import com.alipay.api.domain.ShopMemberInfo;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.woniu.order.mapper.OrderMapper;
import com.woniu.order.pojo.Order;
import com.woniu.shop.mapper.ShopMapper;
import com.woniu.shop.pojo.Shop;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.math.BigDecimal;

public class ShopCommissionUtil {
    @Autowired(required = false)
    private static OrderMapper orderMapper;
    @Autowired(required = false)
    private static BigDecimal shopCommission;

    public static BigDecimal shopCommission(Integer orderId) {
        Order order = orderMapper.selectById(orderId);
        // 判断门店等级

        // 判断订单金额
        BigDecimal payAmount = order.getPayAmount();
        if (payAmount.compareTo(new BigDecimal(20)) == -1) {
            shopCommission = payAmount.multiply(new BigDecimal(0.1));
        } else if (payAmount.compareTo(new BigDecimal(50)) == -1) {
            shopCommission = payAmount.multiply(new BigDecimal(0.15));
        } else {
            shopCommission = payAmount.multiply(new BigDecimal(0.2));
        }
        return shopCommission;

    }

}

